var lbt = document.getElementById("lby-lbt");
var byyul = document.getElementById("byyul");
var li = byyul.getElementsByTagName("li");
var a = 0;
aaa = setInterval(baod, 2000)

function baod() {
	a += 100;
	if(a <= 400) {
		lbt.style.marginLeft = "-" + a + "%";
		for(var i = 0; i < 5; i++) {
			li[i].style.background = "#fff";
		}
		li[a / 100].style.background = "#000";
	} else {
		a = 0;
		lbt.style.marginLeft = "-" + a + "%";
		for(var i = 0; i < 5; i++) {
			li[i].style.background = "#fff";
		}
		li[0].style.background = "#000";
	}
}

setInterval(function() {
	byyul.onmouseover = function() {
		clearInterval(aaa);
		byyul.style.background = "aqua";
		console.log("停止自动轮播图");
	}
	byyul.onmouseleave = function() {
		aaa = setInterval(baod, 2000)
		byyul.style.background = "#bbb";
		console.log("开始自动轮播图");
	}
	for(var h = 0; h < 5; h++) {
		li[h].onclick = function() {
			for(var i = 0; i < 5; i++) {
				li[i].index = i;
				li[i].style.background = "#fff";
				if(this == li[0]) {
					a = 0;
				} else {
					if(this == li[1]) {
						a = 100;
					} else {
						if(this == li[2]) {
							a = 200;
						} else {
							if(this == li[3]) {
								a = 300;
							} else {
								if(this == li[4]) {
									a = 400;
								}
							}
						}
					}
				}
				lbt.style.marginLeft = "-" + a + "%";
//				console.log("当前在" + parseInt(a / 100 + 1) + "页");
			}
			this.style.background = "#000";
		}
	}
})